**=================================**
** Mettler,Zhu and Jacobs APSR2022 **
** Threat, Partisanship and ACA	   **
** Do File for Recoding Variables  **
** Last Update on May 23, 2022     **
**=================================**

clear
* Zhu directory
cd "/Users/lingzhu/Dropbox/JacobsMettlerZhu/APSR2022 Dataverse/"
use "1.MZJ APSR Data Longformat.dta"

* Generate Wave ID
gen wave=year
recode wave (2010=1) (2012=2) (2014=3) (2016=4) (2018=5)

* Generate the Age variable
gen age= year-yearbrth
drop yearbrth 

* Recode variable insured (1=insured, 2=not insured) into a dummy variable
gen insured2=insured
recode insured2 (2=0)
drop insured

* Rename "healthbl" as Favorability
gen favorability=healthbl
drop healthbl

* Generate the "threat" variable, using year2018
gen year2018=0
recode year2018 (0=1) if year==2018

order qkey_alt year wave favorability votehlth2 year2018 party7pt impcaccs income35k ///
	  female raceethc age education polknowl insured2 govtinsured

* Generate the three interaction terms
gen party_yr2018=party7pt*year2018
gen access_yr2018=impcaccs*year2018
gen income_yr2018=income35k*year2018

* Generate two lagged dependent variables
xtset qkey_alt wave
* Lagged favoribility score
bys qkey_alt: gen l_favorability=l.favorability
* Lagged DV: Health issue importance for voting
bys qkey_alt: gen l_vote=l.votehlth2
	  
save "3.MZJAPSR2022 Replication Data.dta", replace

